package com.weixin.servlet;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

import com.weixin.service.IDeleteAboutService;
import com.weixin.service.impl.DeleteAboutServiceImpl;

@WebServlet("/DeleteAboutServlet/*")
public class DeleteAboutServlet extends HttpServlet {
	private static Logger logger = Logger.getLogger(DeleteAboutServlet.class); 
	IDeleteAboutService deleteservice=new DeleteAboutServiceImpl();
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String path=request.getPathInfo().substring(1);
		if("deletPurchaseTb".equals(path)) {
			DeletPurchaseTb(request,response);
		}else if("deletGoodsTb".equals(path)){
			DeletGoodsTb(request,response);
		}else if("deletNoInspect".equals(path)){
			DeletNoInspect(request,response);
		}else if("deletNoInStorehouse".equals(path)){
			DeletNoInStorehouse(request,response);
		}else if("deletInStorehouse".equals(path)){
			DeletInStorehouse(request,response);
		}
	}
	private void DeletInStorehouse(HttpServletRequest request, HttpServletResponse response) {
		try {
			if(deleteservice.deleteInStorehouse()) {
				logger.error("删除入库采购信息");
				response.getWriter().print(1);
			}else {
				response.getWriter().print(0);
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			logger.error(e);
		}
	}
	private void DeletNoInStorehouse(HttpServletRequest request, HttpServletResponse response) {
		try {
			if(deleteservice.deleteNoInStroehouse()) {
				logger.error("删除未入库信息");
				response.getWriter().print(1);
			}else {
				response.getWriter().print(0);
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			logger.error(e);
		}
	}
	private void DeletNoInspect(HttpServletRequest request, HttpServletResponse response) {
		try {
			if(deleteservice.deleteNoIspect()) {
				logger.error("删除未审核信息");
				response.getWriter().print(1);
			}else {
				response.getWriter().print(0);
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	private void DeletGoodsTb(HttpServletRequest request, HttpServletResponse response) {
		try {
			if(deleteservice.deleteGoodsTb()) {
				logger.error("删除商品表");
				response.getWriter().print(1);
			}else {
				response.getWriter().print(0);
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			logger.error(e);
		}
	}
	private void DeletPurchaseTb(HttpServletRequest request, HttpServletResponse response) {
		try {
			if(deleteservice.deletePurchaseTb()) {
				logger.error("删除采购表");
				response.getWriter().print(1);
			}else {
				response.getWriter().print(0);
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			logger.error(e);
		}
		
	}
}
